package com.example.jiaju;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import androidx.viewpager2.widget.ViewPager2;


import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.window.SplashScreen;

import com.example.jiaju.adapter.IntroductoryAdapter;
import com.gyf.immersionbar.ImmersionBar;

import java.util.ArrayList;
import java.util.List;

/**
 * @author starr
 */
public class IntroductoryActivity extends AppCompatActivity {

    private ViewPager viewPager2_introductory;
    private Button button_into;
    private List<View> viewList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        SplashScreen splashScreen = null;
        setContentView(R.layout.activity_introductory);

        initView();
        initAdapter();
        initStart();
        ImmersionBar.with(this).statusBarDarkFont(true).init();
    }

    private void initStart(){

        button_into=viewList.get(2).findViewById(R.id.into);
        button_into.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                    startActivity(new Intent(IntroductoryActivity.this, LoginActivity.class));
                    IntroductoryActivity.this.finish();
            }
        });
    }

    private void initAdapter(){
        IntroductoryAdapter adapter=new IntroductoryAdapter(viewList);
        viewPager2_introductory.setAdapter(adapter);
    }

    private void initView(){
        viewPager2_introductory=findViewById(R.id.viewpager_introductory);
        viewList=new ArrayList<>();
        viewList.add(getView(R.layout.introductory_a));
        viewList.add(getView(R.layout.introductory_b));
        viewList.add(getView(R.layout.introductory_c));
    }

    private View getView(int resid){
        return LayoutInflater.from(this).inflate(resid,null);
    }

}